#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

typedef enum {A,B,C,D,E,F} gradeType;
using namespace std;

class BestCoder
{
	char* name;
	gradeType grade;
	int age;
public:
	BestCoder()
	{
		name = (char*) malloc(40*sizeof(char));
		sprintf(name,"N/a");
		grade = F;
		age = 20;
	}
	~BestCoder()
	{
		free(name);
	}
	void print()
	{
		cout << "Name:" << name << endl;
	}
friend void ChangeName(BestCoder *bc, char* newName); // Friend function declared here will be able to access private member of class
};

void ChangeName(BestCoder *bc, char* newName)
{
	sprintf(bc->name,"%s",newName);
}
int main(int argc, char** argv)
{
	BestCoder m_bc;
	m_bc.print();
	char * name = new char;
	sprintf(name,"DUC MY");
	ChangeName(&m_bc, name);
	delete name;
	m_bc.print();
}

